<!DOCTYPE html>
<html>
    <head>
        <title>reverse</title>
    </head>
    <body>
        <div id="a">
            <span>1</span>
            <p>2</p>
            <a>3</a>
            <div>4</div>
        </div>
    </body>

    <script>
        let element = document.getElementById("a");

        function reverseChildren(element) {
            var l = element.childNodes.length;
            while (l-- > 0) {
                element.appendChild(element.childNodes[l]);
            }

        }

        reverseChildren();
    </script>
</html>